Skip to content

Commit 32c381c

Browse files
authored
test: validate the output of run-task transforms against the schema (#692)
1 parent 7f731f6 commit 32c381c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/test_transforms_run_run_task.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
from taskgraph.transforms.run import make_task_description
11-
from taskgraph.transforms.task import payload_builders
11+
from taskgraph.transforms.task import payload_builders, set_defaults
1212
from taskgraph.util.caches import CACHES
1313
from taskgraph.util.schema import Schema, validate_schema
1414
from taskgraph.util.templates import merge
@@ -23,6 +23,7 @@
2323
"implementation": "docker-worker",
2424
"os": "linux",
2525
"env": {},
26+
"max-run-time": 0,
2627
},
2728
"run": {"using": "run-task", "command": "echo hello world"},
2829
}
@@ -70,6 +71,7 @@ def assert_docker_worker(task):
7071
"-cx",
7172
"echo hello world",
7273
],
74+
"docker-image": {"in-tree": "image"},
7375
"env": {
7476
"CI_BASE_REPOSITORY": "http://hg.example.com",
7577
"CI_HEAD_REF": "default",
@@ -82,6 +84,7 @@ def assert_docker_worker(task):
8284
"VCS_PATH": "/builds/worker/checkouts/vcs",
8385
},
8486
"implementation": "docker-worker",
87+
"max-run-time": 0,
8588
"os": "linux",
8689
"taskcluster-proxy": True,
8790
},
@@ -117,6 +120,7 @@ def assert_generic_worker(task):
117120
"VCS_PATH": "build/src",
118121
},
119122
"implementation": "generic-worker",
123+
"max-run-time": 0,
120124
"mounts": [
121125
{"cache-name": "checkouts", "directory": "build"},
122126
{
@@ -175,7 +179,7 @@ def assert_run_task_command_generic_worker(task):
175179
"task",
176180
(
177181
pytest.param(
178-
{"worker": {"os": "linux"}},
182+
{"worker": {"os": "linux", "docker-image": {"in-tree": "image"}}},
179183
id="docker_worker",
180184
),
181185
pytest.param(
@@ -193,12 +197,14 @@ def assert_run_task_command_generic_worker(task):
193197
"run": {
194198
"exec-with": "powershell",
195199
},
200+
"worker": {"docker-image": "powershell"},
196201
},
197202
id="exec_with",
198203
),
199204
pytest.param(
200205
{
201206
"run": {"run-task-command": ["/foo/bar/python3", "run-task"]},
207+
"worker": {"docker-image": "python"},
202208
},
203209
id="run_task_command_docker_worker",
204210
),
@@ -221,6 +227,12 @@ def test_run_task(monkeypatch, request, run_task_using, task):
221227
param_id = request.node.callspec.id
222228
assert_func = globals()[f"assert_{param_id}"]
223229
assert_func(taskdesc)
230+
taskdesc = next(set_defaults({}, [taskdesc]))
231+
validate_schema(
232+
payload_builders[taskdesc["worker"]["implementation"]].schema,
233+
taskdesc["worker"],
234+
"validation error",
235+
)
224236

225237

226238
@pytest.fixture

0 commit comments

Comments
 (0)